/**
* \brief Implementation of 'Object Factory' design pattern.
*	 Source file.
* \author Bartosz Kedra (bartosz.kedra@gmail.com)
*/
#include "ex4_1.hpp"
#include <boost/shared_ptr.hpp>
#include <vector>

typedef boost::shared_ptr<Worker> WorkerPtr;
typedef std::vector<WorkerPtr> Workers;

class WorkerFactory
{
public:
	static WorkerFactory& getInstance(void)
	{
		static WorkerFactory instance;
		return instance;
	}
	Workers* readFromStream(std::istream &is)
	{
		Workers* workers = new Workers();
		is.exceptions(std::istream::eofbit | std::istream::failbit | std::istream::badbit);
		try
		{
			Worker::Type type;
			while(1)
			{
				//is >> type;
				switch(type)
				{
					case Worker::Season: workers->push_back(WorkerPtr(new SeasonWorker)); break;
					case Worker::Specialist: workers->push_back(WorkerPtr(new SpecialistWorker())); break;
					case Worker::Director: workers->push_back(WorkerPtr(new DirectorWorker())); break;
					default: break;	
				}
			}
		}
		catch (std::istream::failure e)
		{
			if(!is.eof())
			{
				std::cout << e.what() << std::endl;
			}
		}
		return workers;	
	}	
};

int main()
{
return 0;	
}

